<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<title>重设密码</title>
<link rel="shortcut icon" href="${ctx}/resources/imgs/favicon.ico" />
<link rel="stylesheet" href="${ctx}/resources/css/manager/resetPwd.css" />
<link rel="stylesheet" href="${ctx}/resources/vendor/fontawesome/css/font-awesome.min.css" />
<link rel="stylesheet" href="${ctx}/resources/vendor/fullpage/jquery.fullpage.min.css" />
<script type="text/javascript" src="${ctx}/resources/vendor/jquery/jquery-1.11.3.min.js"></script>
<script type="text/javascript">$.extend({"ctx": "${ctx}"});</script>
<script type="text/javascript" src="${ctx}/resources/vendor/fullpage/jquery.fullpage.min.js"></script>
<script>
$(function(){

	var resetClickBtn, resetPwdContainer = ".resetPwdContainer", errorContainer = ".errorContainer" ;
	$("#fullpage").fullpage({
		slidesNavigation: false,
		navigation: false,
	});
	if("${resp.status?string('true', 'false')}" == "true") {
		$(resetPwdContainer).show();
		$("input").val("");
		
		var l = $("#submit").bind("click", resetClickBtn = function(){
			resetPwd() ;
		});
		
		function resetPwd(){
			l.unbind("click");
			var id = "${(resp.obj.id)!}";
			var username = "${(resp.obj.username)!}";
			var validateCode = "${(resp.obj.validateCode)!}";
			var password = $("input[name=password]").val();
			var password1 = $("input[name=password1]").val();
			
			if("" == password.trim() && "" == password1.trim()){alert("密码不能为空！");return;}
			if(password.trim() === password1.trim()) {
				$.post($.ctx+"/manager/system/user/changePwd", {"id": id, "username": username, "validateCode": validateCode, "password": password}, function(result) {
					if(result.status) {
						$(".reset-info").html(result.message).css("color", "green");
						setTimeout(function(){		
							window.location.replace($.ctx+"/manager/login");
						},500);
					} else {
						l.bind("click", resetClickBtn) ;
						$(".reset-info").html(result.message).css("color", "red");
					}
				},"JSON");
			} else {
				alert("确认密码与新密码不相同！") ;
				return ;
			}
		}
		
	} else {
		$(errorContainer).show();
		$(".error-info").html("${resp.message!}"+"<br><a href='"+$.ctx+"/manager/login#iForgot'>重新申请</a>");
	}
});
</script>
</head>

<body>
${resp.message}
${resp.status?string("true","false")}
${(resp.obj.id)!}
<#if resp.obj??>
	${resp.obj.id}
</#if>

	<div id="fullpage">
		<div class="section resetpwd">
			<div class="resetPwdContainer">
				<div class="reset-main">
					<h4><i class="fa fa-coffee"></i>重设密码</h4> 
					<fieldset>
						<label>
							<span class="block">
								<input type="password" class="form-control" name="password" placeholder="新密码" />
								<i class="fa fa-lock"></i>
							</span>
						</label>
						<label>
							<span class="block">
								<input type="password" class="form-control" name="password1" placeholder="确认密码" />
								<i class="fa fa-lock"></i>
							</span>
						</label>
						<div class="space"></div>
						
						<div class="btn-box">
							<button class="reset-btn" id="submit">
								<i class="ace-icon fa fa-key"></i>
								<span class="bigger-110">提交</span>
							</button>
						</div>
					</fieldset>
					
					<div class="social-or-reset center">
						<span class="reset-info"></span>
					</div>
				</div>
			</div>
			
			<div class="errorContainer">
				<div class="error-main">
					<h4><i class="fa fa-times"></i>&nbsp;<span class="error-info"></span></h4> 
				</div>
			</div>
		</div>
		
	</div>
</body>
</html>